Component Objects: C Nested Structures

C interface implementations comprise data structures nested within the object s data structure. Each interface structure contains a VTBL pointer as its first member (pVtbl), a pointer to the object (pCObj), and a count of the external references to the interface (m_RefCount). The order of the members in the interface structures is identical, to facilitate code sharing.

typedef struct CObj { 

  ULONG            m_ObjRefCount;

  LPSTORAGE        m_pStg;

  LPOLEOBJECT      m_pOleObj;

  struct CDOC    *  m_pCDoc;

 

  struct InterfaceA 

    LPVTBL        pVtbl;

    struct CObj  *  pCObj;

    ULONG        m_RefCount;

  } m_InterfaceA;

 

  struct InterfaceB { 

    LPVTBL       pVtbl;

    struct Obj  *    pCObj;

    ULONG        m_RefCount;

  } m_InterfaceB;

 

} COBJ;